package stringbuilder01;
/*
* StringBuilder的成员方法:
* append()方法:不断向容器的末尾追加任意类型的数据
*  StringBuilder append(boolean b)
*           将 boolean 参数的字符串表示形式追加到序列。
*  StringBuilder append(char c)
*           将 char 参数的字符串表示形式追加到此序列。
*  StringBuilder append(char[] str)
*           将 char 数组参数的字符串表示形式追加到此序列。
*  int length()
*           返回容器中字符的个数
*
*String substring(int start, int end)
*   返回一个新的String,从[start索引，end索引)截取一段字符
*StringBuilder delete(int start, int end)
*   返回截取之后的字符序列,从[start索引，end索引)删除其间的字符
* StringBuilder reverse()
*   反转这个容器中的内容,将此字符序列用其反转序列代替
*
* */
public class StringBuilderDemo02 {
    public static void main(String[] args) {
        //method01();
        //method02();
        //method03();
        //method04();
        //method05();
        StringBuilder stringBuilder = new StringBuilder("你今天真棒");
        stringBuilder.reverse();
        System.out.println(stringBuilder);

    }

    private static void method05() {
        StringBuilder stringBuilder = new StringBuilder("losbn");
        stringBuilder.delete(1, 3);
        System.out.println(stringBuilder);
    }

    private static void method04() {
        StringBuilder stringBuilder = new StringBuilder("afkln");
        String str = stringBuilder.substring(1, 3);
        System.out.println(str);
    }

    private static void method03() {
        StringBuilder stringBuilder = new StringBuilder();
        System.out.println(stringBuilder.length());
        stringBuilder.append(123);
        stringBuilder.append("abc");
        System.out.println(stringBuilder.length());
    }

    private static void method02() {
        StringBuilder stringBuilder = new StringBuilder("cd");//cd
        char[] chars = {'3', 'a'};
        stringBuilder.append(chars);//cd->3a
        stringBuilder.append(false);//cd3a->false
        System.out.println(stringBuilder);//"cd3afalse"
    }

    private static void method01() {
        StringBuilder stringBuilder = new StringBuilder();//空的容器
        stringBuilder.append(5);//append()方法就是向容器中追加数据
        stringBuilder.append("abc");
        System.out.println(stringBuilder);
    }
}
